# Contributor: Anjandev Momi <anjan@momi.ca>
# Contributor: Guy Godfroy <guy.godfroy@gugod.fr>
# Maintainer: Anjandev Momi <anjan@momi.ca>
pkgname=biboumi
pkgver=9.0
pkgrel=7
pkgdesc="XMPP to IRC gateway"
options="!check" # has no tests
url="https://biboumi.louiz.org/"
arch="all"
license="Zlib"
pkgusers="biboumi"
pkggroups="biboumi"
makedepends="
	botan-dev
	cmake
	expat-dev
	gnu-libiconv-dev
	libidn-dev
	libpq-dev
	udns-dev
	util-linux-dev
	samurai
	"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://git.louiz.org/biboumi/snapshot/biboumi-$pkgver.tar.xz
	$pkgname.initd
	"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-Wno-dev \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DWITH_BOTAN=True \
		-DWITHOUT_SYSTEMD=False \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install

	install -Dm755 "$srcdir"/biboumi.initd "$pkgdir"/etc/init.d/biboumi
	install -Dm644 "$builddir"/conf/biboumi.cfg "$pkgdir"/etc/biboumi/biboumi.cfg.example

	rm -rf "$pkgdir"/usr/lib/systemd
}

sha512sums="
cfaacd831b56031906922472275c55fd6f1a5307ebe54959d21e3799ad4612499e8beeb34e8736df9eabc9fec1a861d17567250d64f316ace47395fd6c8f3c18  biboumi-9.0.tar.xz
0a7fe41c1455ffc8a9d524795ea3c2591290d8414f3ed51a33dd0548d1acb00a218c5dd451a5705540f754b466097c834ada777db07df892c7347be75d129039  biboumi.initd
"
